package cn.itsource.feign.fallback;

import cn.itsource.domain.Login;
import cn.itsource.dto.LoginMealDto;
import cn.itsource.feign.client.LoginFeignClient;
import cn.itsource.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFeignClientFallbackFactory implements FallbackFactory<LoginFeignClient> {

    @Override
    public LoginFeignClient create(Throwable throwable) {
        return new LoginFeignClient() {
            @Override
            public JSONResult save(Login login) {
                return JSONResult.error("服务降级,注册保存失败");
            }

            @Override
            public JSONResult saveLoginMeal(LoginMealDto meal) {
                return JSONResult.error("服务降级,服务套餐保存失败");
            }
        };
    }
}
